import axios from "axios";

class Service{
    require_homework(obj){
        let week = [];
        let data = [];
        axios.get("/api/require_homework")
            .then(response => {
                console.log(typeof response.data);
                // 条形图
                for (let key in response.data){
                    week.push(key);
                    data.push(response.data[key]);
                }
                obj.draw_graph(week, data);
                // 饼形图
                data = [];
                for (let key in response.data){
                    data.push({"value": response.data[key], "name": key})
                }
                obj.draw_pie(data);
            })
            .catch(error => console.log(error))
    }
}

let service = new Service();
export {service};